//https://blog.csdn.net/weixin_42289080/article/details/130725695
import {defineStore} from 'pinia';

//参数一：容器id必须唯一;
export default defineStore('main', {
    state: () => {//必须是箭头函数
        return {
            appKey:"screen",//当前应用Key
            token:"",//当前token
            user:"",//当前用户
            appId:"", //应用ID
            selectedKey:"",//选择的菜单name
        }
    },
    //类似组件的computed,有缓存的功能
    getters: { },
    //类似组件的methods  封装业务逻辑  修改state
    actions: {
        setAppKey(appKey) {
            this.appKey = appKey;
        },
        setAppId(appId){
            this.appId = appId;
        },
        setUser(user){
            this.user = user ;
        },
        setToken(token) {
            this.token = token;
        },
        setSelectedKey(selectedKey) {
            this.selectedKey = selectedKey;
        },
    }
})




